You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR removes the "-RunAhead" command line so that a couple of global network variables can be marked static conststatic constexpr const for safety and performance. Considering that the "RunAhead" command is for development only and likely rarely used, I think it's ok to get rid of it.
The current setup with extern in the header and definition in the source file causes the compiler to miss out on optimizations. It's possible that link time optimization would fix this, but that's not currently used.
This PR converts five mutable extern network global variables (MIN_LOGIC_FRAMES, MAX_FRAMES_AHEAD, MIN_RUNAHEAD, FRAME_DATA_LENGTH, FRAMES_TO_KEEP) into static constexpr const inline constants in NetworkDefs.h, and removes the -RunAhead command-line option that was the only runtime mutation point for three of them.
NetworkDefs.h: Declarations moved from extern to static constexpr const; derived constants (FRAME_DATA_LENGTH, FRAMES_TO_KEEP) are now computed at compile time from MAX_FRAMES_AHEAD. Using static gives internal linkage, preventing ODR violations across translation units.
NetworkUtil.cpp: Variable definitions deleted; tweak comment relocated to the header alongside the constants.
CommandLine.cpp (both Generals and GeneralsMD): parseRunAhead() and the { "-RunAhead", … } table entry removed identically in both targets.
Confidence Score: 5/5
Safe to merge — the change is a straightforward constexpr promotion with no behavioural difference at runtime.
The network constants had fixed values in the source file and the only mutation path (-RunAhead) is being intentionally removed. Making them static constexpr in the header is correct and consistent: static gives internal linkage (no ODR issue across TUs), constexpr enables compile-time evaluation, and the derived constants FRAME_DATA_LENGTH and FRAMES_TO_KEEP are computed from MAX_FRAMES_AHEAD at compile time just as they were at startup before. Both Generals and GeneralsMD are updated identically.
No files require special attention.
Important Files Changed
Filename
Overview
Core/GameEngine/Include/GameNetwork/NetworkDefs.h
Replaces five extern variable declarations with static constexpr const inline definitions; upgrades other static const constants to constexpr. Change is correct — static linkage prevents ODR issues and constexpr enables full compile-time evaluation.
Removes the five global variable definitions that are now inline constexpr in the header; the tweak comment is moved to the header alongside the constants.
Rebased to include the fix for the CI Replay checker.
xezon
changed the title
perf(network): Remove extern and add const to global network variables
perf(network): Replace extern global network variables with const ones
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MinorSeverity: Minor < Major < Critical < BlockerNetworkAnything related to network, serversPerformanceIs a performance concern
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes the "-RunAhead" command line so that a couple of global network variables can be marked
static conststatic constexpr constfor safety and performance. Considering that the "RunAhead" command is for development only and likely rarely used, I think it's ok to get rid of it.The current setup with
externin the header and definition in the source file causes the compiler to miss out on optimizations. It's possible that link time optimization would fix this, but that's not currently used.TODO: